package cn.francis.chatplatform.modules.message.controller;

import cn.francis.chatplatform.modules.message.dto.StartCommunicationDTO;
import cn.francis.chatplatform.modules.message.service.ChatMessageService;
import cn.francis.common.core.model.AppResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.time.Duration;

/**
 * @author 张俊辉
 */

@Slf4j
@RestController
@Tag(name = "同步对话")
@RequiredArgsConstructor
@RequestMapping("sync/communicate")
public class SyncCommunicateController {

    private final ChatMessageService chatMessageService;

    @PostMapping
    public AppResponse<String> execute(@RequestBody StartCommunicationDTO startCommunicationDTO) {

        Long sessionId = startCommunicationDTO.getSessionId();
        String question = startCommunicationDTO.getQuestion();
        String response = chatMessageService.communicate(sessionId, question);

        return AppResponse.ok(response);
    }
}
